package com.xiaozhou.tekv;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 泛型
 */
public class Generic {

    /**
     * extends 泛型：设定泛型上限 ：只能是Number的子类 用处是可以安全的读取数据。不能插入数据
     * @param list 泛型集合
     */
    public void printlnNumberList(List<? extends Number> list){
        for (Number number : list) {
            System.out.println(number);
        }
    }

    public List<Number> setNumberList(Number number){
        List<Number> objects = new ArrayList<>();
        if (number != null){
            objects.add(number);
        }
        return objects;
    }

    public static void main(String[] args) {

        Optional<Object> o = Optional.ofNullable(null);
        Optional<String> s = o.flatMap( o1 -> Optional.ofNullable(o1.toString()));
        System.out.println("");

    }
}
